﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Media;

namespace Tetris
{
    class MusicPlayer
    {
        private Thread playThread;

        public void PlayMusic()
        {
            if (playThread == null)
            {
                playThread = new Thread(PlayTetrisMusic);
                playThread.Start();
            }
        }

        public void StopMusic()
        {
            playThread.Abort();
        }

        public void PlayTetrisMusic()
        {
            MediaPlayer song = new MediaPlayer();
            for (;;)
            {
                song.Open(new Uri("D:\\console app\\Inteducation\\Oleksyuk\\Tetris\\sound.mp3", UriKind.Absolute));
                song.Play();
                Thread.Sleep(246000);//не нашел, как по-другому дать мелодии доиграть до конца, перед перезапуском
                song.Close();
            }
            
            

        }
    }
}
